'''
Created on Aug 25, 2011

@author: david
'''

from pspy.gae.actiondomain import PspyAction

class Poke(PspyAction):
    
    def execute(self):
        import logging, time
        
        logging.debug("~~ Execute: Poke")
        req = self.request
 
        # set of insults (TODO: set in datastore) 
        insults = ["Jerk!","Twit!","Idiot!","Your Mother was a Hamster!",
                   "Dolt!","Schmuck!","You Wiper of Other Peoples Bottoms!",
                   "Putz!","Piss Off!","Your Father Smelled of Elderberry","Bugger Off!",
                   "Butt Head!", "Go Away!"]
        
        # psuedo randomness
        i = int(time.time()) % len(insults)
        
        # respond to request
        req.setResponsePage(None)
        
        rsp = req.getResponse()
        rsp.output = "{ 'response':'%s' }" % insults[i]
        logging.debug("~~ Output: %s" % rsp.output)
        return rsp
    
    def sess_check(self):
        return True